package graph;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

public class AbstractNode {

    private NodeType type;
    private Set<String> labels=new HashSet<String>();
    private String debugId = "";
    private boolean VERBOSE = true;
    
    
    public AbstractNode(NodeType type, String label) {
        this.type = type;
        this.labels.add(label);
        this.debugId = type.toString();
    }
    
    public AbstractNode(NodeType type, Collection<String> labels) {
        this.type = type;
        this.labels.addAll(labels);
        this.debugId = "NULL";
    }
    
    public NodeType getType() {
        return type;
    }

    public String toString() {
        if (VERBOSE) {
            return type.toString().concat("\n").concat(labels.toString()).concat("\n").concat(debugId);            
        }
        return debugId;
    }

    public boolean hasSubsetOfLabels(GNode node) {
        for (String label : this.getLabels()) {
            if (!node.getLabels().contains(label)) {
                return false;
            }
        }
        return true;
    }
    
    public String getLabelsString() {
        return labels.toString();
    }

    public String getDebugId() {
        return debugId;
    }
    
    public void addLabel(String label) {
        this.labels.add(label);
    }

    public Collection<String> getLabels() {
        return labels;
    }
    
    public void removeLabel(String label) {
        labels.remove(label);
    }
    
    public void removeLabels(String[] labels) {
        this.labels.removeAll(Arrays.asList(labels));
    }

    public void addLabels(Collection<String> labels) {
        this.labels.addAll(labels);
    }
    
    public void addLabels(String[] labels) {
        this.labels.addAll(Arrays.asList(labels));
    }
}
